home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_test / test_real.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  2.3 KB  |  122 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_REAL
  5.  
  6. creation {ANY}
  7.    make
  8.    
  9. feature {ANY}
  10.    
  11.    make is
  12.       local
  13.      i: INTEGER;
  14.      r: REAL;
  15.       do
  16.      is_true(1. = 1.);
  17.      is_true(0.0 = 0.);
  18.      is_true(1.05 = 1.050);
  19.  
  20.      
  21.      r := 1.6;
  22.      is_true(r = r);
  23.      is_true(r = 1.6);
  24.      is_true(r >= 1.59);
  25.      is_true(r <= 1.61);
  26.      
  27.      is_true(1. < 1.1);
  28.      is_true(1. <= 1.1);
  29.      is_true(0. < 0.5);
  30.      is_true(0. <= 0.5);
  31.      is_true(-0.5 < 0.);
  32.      is_true(-0.5 <= 0.5);
  33.      is_true(-1.5 < 1.5);
  34.      is_true(-1.5 <= 1.5);
  35.      
  36.      is_true(1.1 > 1.);
  37.      is_true(1.1 > 1);
  38.      is_true(1.1 >= 1.);
  39.      is_true(1.1 >= 1);
  40.      is_true(0.5 > 0.);
  41.      is_true(0.5 > 0);
  42.      is_true(0. > -0.5);
  43.      is_true(0.5 >= -0.5);
  44.      is_true(1.5 > -1.5);
  45.      is_true(1.5 >= -1.5);
  46.      
  47.      
  48.      is_true(1. + 1. = 2.0);
  49.      
  50.      is_true(+1.5 = 1.5);
  51.      is_true(-1.5 = - +1.5);
  52.      
  53.      r := 2;
  54.      is_true(r = 2.0);
  55.      
  56.      i := 2;
  57.      r := i;
  58.      is_true(r = 2);
  59.      is_true(r = 2.0);
  60.       
  61.      is_true((3.5).floor = 3);
  62.      is_true((3.5).ceiling = 4);
  63.       
  64.      is_true((-3.5).floor = -4);
  65.      is_true((-3.5).ceiling = -3);
  66.       
  67.            is_true((0.6).floor = 0);
  68.      is_true((0.4).ceiling = 1);
  69.      
  70.      is_true((0.4).truncated_to_integer = 0);
  71.      is_true((0.51).truncated_to_integer = 1);
  72.      is_true((1.49).truncated_to_integer = 1);
  73.      is_true((1.51).truncated_to_integer = 2);
  74.      
  75.      r := (1.51).to_string.to_real;
  76.      is_true(r < 1.511);
  77.      is_true(r > 1.509);
  78.       
  79.            r := (-1.51).to_string.to_real;
  80.      is_true(r > -1.52);
  81.      is_true(r < -1.50);
  82.      
  83.      is_true(r.abs < 1.52);
  84.      is_true(r.abs > 1.50);
  85.      is_true((-r).abs < 1.52);
  86.      is_true((-r).abs > 1.50);
  87.      
  88.      is_true((3.5).min(4.5) = 3.5);
  89.      is_true((4.5).min(3.5) = 3.5);
  90.      
  91.      is_true((3.5).max(4.5) = 4.5);
  92.      is_true((4.5).max(3.5) = 4.5);
  93.       
  94.            is_true((-3.5).min(-4.5) = -4.5);
  95.      is_true((-4.5).min(-3.5) = -4.5);
  96.      
  97.      is_true((-3.5).max(-4.5) = -3.5);
  98.      is_true((-4.5).max(-3.5) = -3.5);
  99.       
  100.      r := 3.1 ^ 2;
  101.      is_true(r > 9.6099989);
  102.      is_true(r < 9.6199999);
  103.      
  104.      is_true((4.0).sqrt = 2.0);
  105.       end;
  106.    
  107.    is_true(b: BOOLEAN) is
  108.       do
  109.      cpt := cpt + 1;
  110.      if not b then
  111.         std_output.put_string("TEST_REAL: ERROR Test # ");
  112.         std_output.put_integer(cpt);
  113.         std_output.put_string("%N");
  114.      else
  115.         -- std_output.put_string("Yes%N");
  116.      end;
  117.       end;
  118.    
  119.    cpt: INTEGER;
  120.    
  121. end -- TEST_REAL
  122.